package megrez.mail.sender.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ITemplateResolver;
import org.thymeleaf.templateresolver.StringTemplateResolver;

import lombok.RequiredArgsConstructor;

/**
 * Thymeleaf模板配置。
 *  
 * @author Lucky Yang
 * @since 2.6.9
 */
@Configuration
@RequiredArgsConstructor
public class ThymeleafConfiguration {

    @Bean
    public SpringTemplateEngine templateEngine() {
        SpringTemplateEngine templateEngine = new SpringTemplateEngine();
        templateEngine.setTemplateResolver(stringTemplateResolver());
        return templateEngine;
    }

    @Bean
    public ITemplateResolver stringTemplateResolver() {
        final StringTemplateResolver resolver = new StringTemplateResolver();
        resolver.setTemplateMode("HTML5");
        resolver.setCacheable(false);
        return resolver;
    }
}
